package com.wang.wangrpc.loadbalancer;

import com.wang.wangrpc.model.ServiceMetaInfo;

import java.util.List;
import java.util.Map;
import java.util.Random;

/**
 * @Author 王子旭
 * @Date 2025/04/05 23:35
 * @Version 1.0
 */
public class RandomLaodBalancer implements LoadBalancer{

    private final Random random = new Random();
    @Override
    public ServiceMetaInfo select(Map<String, Object> requestParams, List<ServiceMetaInfo> serviceMetaInfoList) {
        if (serviceMetaInfoList.isEmpty()) return null;
        return serviceMetaInfoList.get(random.nextInt(serviceMetaInfoList.size()));
    }
}
